package org.ace.dao.impl;

import org.ace.dao.IAccountDAO;
import org.ace.dao.model.Account;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

public class AccountDAOImpl extends SqlMapClientDaoSupport implements IAccountDAO {

    public AccountDAOImpl() {
        super();
    }

    public void save(Account account) {
        getSqlMapClientTemplate().insert("account.insert", account);
    }

    public int update(Account account) {
        int rows = getSqlMapClientTemplate().update("account.update", account);
        return rows;
    }

    /**
     * 根据需要进行修改，用账号名来查询
     */
    public Account get(String  account) {
        Account key = new Account();
        //key.setId(id);
        key.setAccount(account);
        Account record = (Account) getSqlMapClientTemplate().queryForObject("account.select", key);
        return record;
    }

    public int remove(Integer id) {
        Account key = new Account();
        key.setId(id);
        int rows = getSqlMapClientTemplate().delete("account.delete", key);
        return rows;
    }
}